package ai.mspbots.test.controller;

import ai.mspbots.test.dto.AzureAIConfig;
import ai.mspbots.test.service.AzureConfigManagementService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Azure AI配置管理控制器
 * 
 * @author mspbots
 * @since 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/azure")
@RequiredArgsConstructor
public class AzureConfigController {

    private final AzureConfigManagementService azureConfigManagementService;

    /**
     * 获取所有Azure AI配置
     */
    @GetMapping("/configs")
    public ResponseEntity<List<AzureAIConfig>> getAllAzureConfigs() {
        List<AzureAIConfig> configs = azureConfigManagementService.getAzureAIConfigs();
        return ResponseEntity.ok(configs);
    }

    /**
     * 验证并保存Azure配置
     */
    @PostMapping("/configs/validate")
    public ResponseEntity<Boolean> validateAndSaveAzureConfig(@RequestBody AzureAIConfig config) {
        boolean result = azureConfigManagementService.validateAndSaveAzureConfig(config);
        return ResponseEntity.ok(result);
    }

    /**
     * 批量验证Azure配置
     */
    @PostMapping("/configs/batch-validate")
    public ResponseEntity<Void> batchValidateAzureConfigs(@RequestParam Long integrationId) {
        azureConfigManagementService.batchValidateAzureConfigs(integrationId);
        return ResponseEntity.ok().build();
    }
}
